home *** CD-ROM | disk | FTP | other *** search
- Path: sabik.tdb.uu.se!m92fra
- From: m92fra@sabik.tdb.uu.se (Fredrik Raadesand)
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: Performance: C vs. C++
- Date: 14 Jan 1996 09:17:20 GMT
- Organization: department of Scientific Computing, Uppsala University, Sweden
- Message-ID: <4dahn0$lei@columba.udac.uu.se>
- NNTP-Posting-Host: sabik.tdb.uu.se
-
- In article <30F6BAAC.12B5@iastate.edu> you wrote:
- : Hi,
-
- : I was wondering if anyone could tell me what the difference in performance would be between
- : writing a program in C++ vs. C. Assume that the compilers are both of equal quality. I know
- : that certain features such as virtual functions and exception handling add overhead. Are there
- : any others? If you don't implement these features that add the extra overhead, is C++ directly
- : comparable to C in performance then? The only other reason I could see C++ being slower than C
- : is programming style. Object-oriented is slower since there are more layers, hence function call
- : overhead.
-
- : Anyone with some answers, disagreements? Thanks.
-
- I do not wish to argue about c vs. c++ compilers but I can tell you this...
-
- Last night I did a couple of very simple tests...I made two test's as to
- compare Linux/GNU C compiler vs. DOS/Borland C++ with respect to
- execution speed of looping/integer math and looping/floating point math
- (
- Although my objetive was to compare DOS to Linux and not to
- compare the compilers and the results I guess shows Linux to be superior
- to DOS, but however I thought you c-freaks might be interested anyway :)
- )
-
- Test 1. A simple integration using simpsons algoritm, uses double types.(float)
- DOS/BCC Linux/GCC
- Exec.time: 17.6 sec 10.0 sec
-
- Test 2. A simple loop just counting up a long int counter.(no float here)
- DOS/BCC Linux/GCC
- Exec.time: 12.4 sec 6.6 sec
-
- So if you are interested in performance ? Trash DOS ! I guess running
- DOS on 386-system is like driving a 4-cyl. car with two sparc-plugs ripped
- out, it'll run but it sure is a waste of fuel.
-
- Or maybe this one is even better...
- Running a 4 cyl. car with two sparc plugs ripped out is like running a
- 386-system with 16 bits ripped out, it'll run but it sure looks like DOS
- to me ? :-)
-
- : --
- : Steve Lee
- : Computer Engineering/Computer Science
- : Iowa State University
- : email -> sjlee@iastate.edu
- : WWW -> http://www.cs.iastate.edu/~sjlee/homepage.html
-
- /Fredrik
- m92fra@student.tdb.uu.se
-